#include "../../UserModule/User.hpp"

int main()
{
    MySQLHelper::Ptr mysql_helper = std::make_shared<MySQLHelper>("127.0.0.1", "zchat", "123456", "zchat", 3306);

    UserPersist::Ptr per = std::make_shared<UserPersist>(mysql_helper);

    User::Ptr user1 = per->getUser("000002");


    if(user1 == nullptr)
    {
        std::cout << "没有找到用户，用户id：000002" << std::endl; 
    }
    else
    {
        std::cout << "id: " << user1->getUserid() << std::endl;
        std::cout << "name: " << user1->getUsername() << std::endl;
        std::cout << "password: " << user1->getPassword() << std::endl;
        std::cout << "Sessionid: " << user1->getSessionid() << std::endl;
    }

    per->addUser("rb", "000002", "123456", "1234678123467812346781234678");

    User::Ptr user = per->getUser("000002");


    if(user == nullptr)
    {
        std::cout << "没有找到用户，用户id：000002" << std::endl; 
    }
    else
    {
        std::cout << "id: " << user->getUserid() << std::endl;
        std::cout << "name: " << user->getUsername() << std::endl;
        std::cout << "password: " << user->getPassword() << std::endl;
        std::cout << "Sessionid: " << user->getSessionid() << std::endl;
    }

    return 0;
}